In This Topic
Programming / Document Viewing / Viewing documents from different sources

Viewing documents from different sources

In This Topic
 Viewing images and PDF documents from locally stored files

The GdViewer class is designed to automate most viewing operations for you.

All you have to do is add a GdViewer object to your form and call one of the Display functions, for example DisplayFromFile().

Copy Code
Dim GdViewer1 As New GdViewer()

GdViewer1.DisplayFromFile("")
Copy Code
GdViewer GdViewer1 = new GdViewer();

GdViewer1.DisplayFromFile("");

As you can see, an empty string is passed as the file location parameter. This prompts the function to display an OpenFileDialog, that is linked to the GdViewer. To see, how to create and integrate the GdViewer in your application, please look at your first GdPicture.NET application or try our Document Viewer Sample.

 Viewing GdPictureImage identifiers

Most GdPicture image processing occurs by using GdPictureImage identifiers. Here is a simple code showing how to create a GdPictureImage identifier from a file and then how to view the created image in your GdViewer.

Copy Code
'We assume that GdPicture has been correctly installed and unlocked.

'Initializing the GdPictureImaging object.

Dim oGdPictureImaging As New GdPictureImaging()

Dim GdViewer1 As New GdViewer()

'Loading the image from a file.

Dim imageID As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("")

'Checking if the image has been loaded correctly.

If oGdPictureImaging.GetStat() = GdPictureStatus.OK Then

    'Displaying the image and checking the status.

    If GdViewer1.DisplayFromGdPictureImage(imageID) <> GdPictureStatus.OK Then

        MessageBox.Show("Error occurred when displaying the image. Error: " + GdViewer1.GetStat().ToString(), "Viewing Example", MessageBoxButtons.OK, MessageBoxIcon.Error)

    End If

    'Releasing the image resource.

    oGdPictureImaging.ReleaseGdPictureImage(imageID)

Else

    'Displaying the error message.

    MessageBox.Show("The file can't be loaded. Error:" + oGdPictureImaging.GetStat().ToString(), "Viewing Example", MessageBoxButtons.OK, MessageBoxIcon.Error)

End If

oGdPictureImaging.Dispose()
Copy Code
//We assume that GdPicture has been correctly installed and unlocked.

//Initializing the GdPictureImaging object.

GdPictureImaging oGdPictureImaging = new GdPictureImaging();

GdViewer GdViewer1 = new GdViewer();

//Loading the image from a file.

int imageID = oGdPictureImaging.CreateGdPictureImageFromFile("");

//Checking if the image has been loaded correctly.

if (oGdPictureImaging.GetStat() == GdPictureStatus.OK)

{

    //Displaying the image and checking the status.

    if (GdViewer1.DisplayFromGdPictureImage(imageID) != GdPictureStatus.OK)

    {

        MessageBox.Show("Error occurred when displaying the image. Error: " + GdViewer1.GetStat().ToString(), "Viewing Example", MessageBoxButtons.OK, MessageBoxIcon.Error);

    }

    //Releasing the image resource.

    oGdPictureImaging.ReleaseGdPictureImage(imageID);

}

else

{

    //Displaying the error message.

    MessageBox.Show("The file can't be loaded. Error:" + oGdPictureImaging.GetStat().ToString(), "Viewing Example", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

oGdPictureImaging.Dispose();

To see, how to create and integrate the GdViewer in your application, please look at your first GdPicture.NET application or try our Document Viewer Sample.

 Viewing GdPicturePDF objects

The GdPicturePDF class is a complete class offering features, that allow you easily operate with your PDF documents. If you want to view your changes after creating or loading your PDF documents, just use this simple code snippet:

Copy Code
Dim pdf As New GdPicturePDF()

If (pdf.LoadFromFile("input.pdf", True) = GdPictureStatus.OK) AndAlso

   (pdf.DeletePage(3) = GdPictureStatus.OK) Then

    Dim GdViewer1 As New GdViewer()

    GdViewer1.DisplayFromGdPicturePDF(pdf)

End If

pdf.Dispose()
Copy Code
GdPicturePDF pdf = new GdPicturePDF();

if ((pdf.LoadFromFile("input.pdf", true) == GdPictureStatus.OK) &&

    (pdf.DeletePage(3) == GdPictureStatus.OK))

{

    GdViewer GdViewer1 = new GdViewer();

    GdViewer1.DisplayFromGdPicturePDF(pdf);

}

pdf.Dispose();

To see, how to create and integrate the GdViewer in your application, please look at your first GdPicture.NET application or try our Document Viewer Sample.

 Viewing documents from another sources